
class Inventario {
static final int TAM_INICIAL=10;
Item []v;
int next;
public Inventario() {
this(TAM_INICIAL);
}
public Inventario(int tamInicial) {
if (tamInicial <= 0)
tamInicial = 1;
v = new Item[tamInicial];
next = 0;
}
public int valornext()
{
 return next;	
}
public int longv()
{
  return v.length;	
}
public int getNumItems() {
return next;
}
public void addItem(Item i) {
if (lleno())
duplica();
v[next] = i;
next++;
}
public Item getItem(int i) {
if ((i < 0) || (i >= next))
return null;
return v[i];
}
private void duplica() {
Item [] nuevo = new Item[2 * v.length];
for (int i = 0; i < v.length; ++i)
nuevo[i] = v[i];
// El r e c o l e c t o r e l imi n a r á e l v v i e j o . . .
v = nuevo;
}
private boolean lleno() {
return next == v.length;
}
}